@extends('admin::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" id="form1">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 300px;    ">
                                <input type="text" name="title" value="{{$arr_search['title']}}" placeholder="点击用户名自动填充" autocomplete="off" class="layui-input" >
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="type">
                                    <option value="">类型</option>
                                    <option value="1" @if( $arr_search['type'] == 1  ) selected="" @endif >增加积分</option>
                                    <option value="2" @if( $arr_search['type'] == 2  ) selected="" @endif >扣除积分</option>
                                </select>
                            </div>
                            <input type="hidden" name="user_id" value="{{$arr_search['user_id']}}" >
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                                <span style="margin-left: 20px;">增加积分（总）：<i style="color: red;">{{$sums['add'] }}</i> </span>
                                <span style="margin-left: 20px;">扣除积分（总）：<i style="color: red;">{{$sums['jian'] }}</i> </span>

                            </div>
                        </form>
                    </div>

                    <div class="layui-card-body ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>用户名</th>
                                <th>类型</th>
                                <th>操作积分</th>
                                <th>剩余积分</th>
                                <th>备注</th>
                                <th>操作时间</th>
                            </tr>
                            </thead>
                            <tbody>
                                @foreach($data as $key=>$value)
                                <tr>
                                    <td>{{ $value['id'] }}</td>
                                    <td><a href="#" data-id="{{$value['user_id']}}" title="查看他的明细" class="click_a">{{ $value['get_user']['nickname'] }}</a></td>
                                    <td>{{ $value['type_msg'] }}</td>
                                    <td>{{ $value['deduct'] }}</td>
                                    <td>{{ $value['surplus'] }}</td>
                                    <td>{{ $value['remarks'] }}</td>
                                    <td>{{ $value['created_at'] }}</td>
                                </tr>
                                @endforeach
                                @if(empty($data))
                                    <td colspan="66" align="center">暂无数据</td>
                                @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

            $(".click_a").click(function(){
                var user_id = $(this).attr('data-id');
                $("input[name='user_id']").val( user_id );
                $("input[name='title']").val( $(this).text() );
                $("#form1").submit();
            })
        })
    </script>
@endsection




